package com.jgp.timing.thread;

import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;

import java.util.function.Consumer;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2019/3/31
 */
@Slf4j
public class JobThread implements Job {
    
    @Override
    public void execute(JobExecutionContext context) {
        try {
            JobDataMap dataMap = context.getJobDetail().getJobDataMap();
            Consumer<JobExecutionContext> consumer = (Consumer<JobExecutionContext>)dataMap.get("apply");
            consumer.accept(context);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            log.error("job execute failed!");
        }
    }
    
}
